
// const baseUrl = 'https://tea.qingnian8.com/api/bizhi'
export const http = (params) => {
    const { url, data, method } = params
    return new Promise((resolve, reject) => {
        uni.request({
            url: `https://tea.qingnian8.com/api/bizhi${url}`,
            data,
            header: {
                "access-key": 'xudu123'
            },
            method,
            success: (res) => {
                if (res.data.errCode === 0) {
                    resolve(res.data)
                } else if (res.data.errCode === 400) {
                    uni.showModal({
                        title: '错误提示',
                        content: res.data.errMsg,
                        showCancel: false

                    })
                } else {
                    uni.showToast({
                        title: res.data.errMsg,
                        icon: 'none'
                    })
                    reject(res.data)
                }
            },
            fail: (error) => {
                reject(error)
            }
        })
    })

}